package com.interview.javabase.reflect;

import org.junit.Test;
import org.springframework.boot.test.context.SpringBootTest;

import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 * @author: zsg
 * @description:
 * @date: 2019/6/22 16:43
 * @modified:
 */
@SpringBootTest
public class Demo1 {

    @Test
    public void test1() throws NoSuchFieldException, NoSuchMethodException, IllegalAccessException, InstantiationException, InvocationTargetException {
        Class c = B.class;
        Object o = c.newInstance();
        Field a = c.getDeclaredField("bb");
        a.setAccessible(true);
        System.out.println(a.getName());

        Method aaa = c.getMethod("aaa");
        Object invoke = aaa.invoke(o);

    }
}


class A{
    private String a ="aaa";

    private String b ="bbb";

    public void aaa(){
        System.out.println("method aaa");
    }
}

class B extends A{

    private String bb ="bbbbbb";

    private String bbb ="bbbbbbbbb";
}